<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<title>管理员管理</title>
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet"
	href="${ctx}/plugin/bootstrap/3.3.5/css/bootstrap.min.css">
</head>


<body>

	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<div class="page-header">
					<h1>
						B2C网上商城 <small>Online Shopping Mall</small>
					</h1>
					<ul class="nav nav-pills">
						<li class="pull-right"><c:if test="${admin == null }">
								<a href="${ctx }/view/admin/admin.jsp">管理员登录</a>
							</c:if> <c:if test="${admin != null }">
		                                欢迎你，${admin.adminName }  <button
									type="button" class="btn btn-danger btn-sm" onclick="logout()">退出</button>
							</c:if></li>
					</ul>
				</div>
			</div>
		</div>
		<div class="row clearfix">
			<div class="col-md-2 column">
				<div class="panel-group" id="panel-left">
					<div class="panel panel-danger">
						<div class="panel-heading">
							<a class="panel-title collapsed" data-toggle="collapse"
								data-parent="#panel-left" href="#panel-element-0">管理员管理</a>
						</div>
						<div id="panel-element-0" class="panel-collapse collapse">
							<div class="panel-body">
								<a href="${ctx }/pages/back/admin/showAdminList.do">管理员列表</a>
							</div>
						</div>
					</div>
					<div class="panel panel-info">
						<div class="panel-heading">
							<a class="panel-title" data-toggle="collapse"
								data-parent="#panel-left" href="#panel-element-1">商品管理</a>
						</div>
						<div id="panel-element-1" class="panel-collapse in">
							<div class="panel-body">
								<a href="${ctx }/view/admin/addCategory.jsp">新增商品类别</a>
							</div>
							<div class="panel-body">
								<a href="${ctx }/listCategory.do">商品类别列表</a>
							</div>
							<div class="panel-body">
								<a href="${ctx }/selectCategory.do">新增商品</a>
							</div>
							<div class="panel-body">
								<a href="${ctx }/listProduct.do">商品列表</a>
							</div>
						</div>
					</div>
					<div class="panel panel-default">
						<div class="panel-heading">
							<a class="panel-title collapsed" data-toggle="collapse"
								data-parent="#panel-left" href="#panel-element-2">订单管理</a>
						</div>
						<div id="panel-element-2" class="panel-collapse collapse">
							<div class="panel-body">
								<a href="${ctx }/listOrder.do">订单列表</a>
							</div>
						</div>
					</div>
					<div class="panel panel-warning">
						<div class="panel-heading">
							<a class="panel-title collapsed" data-toggle="collapse"
								data-parent="#panel-left" href="#panel-element-3">用户管理</a>
						</div>
						<div id="panel-element-3" class="panel-collapse collapse">
							<div class="panel-body">
								<a href="${ctx }/listUser.do">注册用户列表</a>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col-md-10 column">
				<ul class="breadcrumb">
					<li><a href="#">后台管理</a></li>
					<li><a href="#">商品管理</a></li>
					<li class="active">管理员列表</li>
				</ul>
				<table
					class="table  table-hover table-condensed  table-striped table-responsive">
					<thead>
						<tr>
							<th>序号</th>
							<th>帐号</th>
							<th>密码</th>
							<th>姓名</th>
							<th>电话</th>
							<th>邮箱</th>
							<th>状态</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="admin" items="${page.datas}" varStatus="status">
							<tr>
								<td>${status.index + 1 }</td>
								<td>${admin.adminId }</td>
								<td>${admin.password }</td>
								<td>${admin.adminName }</td>
								<td>${admin.phone }</td>
								<td>${admin.email }</td>
								<td><c:if test="${admin.status == 0}">
										<font color="red">停用</font>
									</c:if> <c:if test="${admin.status == 1}">
										<font color="green">正常</font>
									</c:if></td>
								<td><c:if test="${admin.status == 0}">
										<a
											href="${ctx }/updateAdminStatus.do?adminId=${admin.adminId }&status=1"
											class="btn btn-success btn-xs">启用</a>
									</c:if> <c:if test="${admin.status == 1}">
										<a
											href="${ctx }/updateAdminStatus.do?adminId=${admin.adminId }&status=0"
											class="btn btn-danger btn-xs">停用</a>
									</c:if></td>
							</tr>
						</c:forEach>
						<tr>
							<td colspan='8' >
								<font color="red">${msg }</font>	
							</td>
						</tr>
					</tbody>
				</table>

				<!-- 分页开始 -->
				<c:if test="${page.total >0 }">
					<script type="text/javascript">
						function gotoSelectedPage() {
							var x = document.getElementById("navigatorForm");
							x.submit();
						}
					</script> 
					<form action="${ctx }/pages/back/admin/showAdminList.do" method="post"
						id="navigatorForm">
						<a href="${ctx }/pages/back/admin/showAdminList.do?cp=1">首页</a>
						<c:if test="${page.currentPage >1 }">
							<a href="${ctx }/pages/back/admin/showAdminList.do?cp=${page.currentPage-1}">上一页</a>
						</c:if>
						跳转到第 <select name="cp" onchange="gotoSelectedPage();">
							<c:forEach begin="1" end="${page.total}" step="1" var="pageIndex">
								<c:choose>
									<c:when test="${pageIndex eq page.currentPage}">
										<option value="${pageIndex}" selected="selected">${pageIndex}</option>
									</c:when>
									<c:otherwise>
										<option value="${pageIndex}">${pageIndex}</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</select>页
						<c:if test="${page.currentPage < page.total}">
							<a href="${ctx }/pages/back/admin/showAdminList.do?cp=${page.currentPage + 1}">下一页</a>
						</c:if>
						<a href="${ctx }/pages/back/admin/showAdminList.do?cp=${page.total}">末页</a>
					</form>
				</c:if>
				<!-- 分页结束 -->
			</div>
		</div>
	</div>


	<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
	<script src="${ctx}/plugin/jquery/1.11.3/jquery.min.js"></script>
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script src="${ctx}/plugin/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<script type="text/javascript">
		function logout() {
			window.location.href = "${ctx}/admin/logout.do"
		}
	</script>
</body>
</html>